package 不会写;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("120.0.0.1",12345);

        //读文件
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\"));
        //输出文件
        //s.getOutputStream() 获取输出io流 才能传输给服务端
        BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
        //拷贝文件
        byte [] bytes = new byte[1024*8];
        int len;
        while ((len =bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
            bos.flush();
        }
        //结束上面流的结束
        s.shutdownOutput();
        bis.close();
        //接受那边服务端来的 数据
        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String s1 = br.readLine();
        System.out.println(s1);
        //释放资源
        br.close();
        s.close();
    }
}
